﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Data.SqlClient;

namespace Framework_Tool
{
    /// <summary>
    /// Interaction logic for StudentView.xaml
    /// </summary>
    public partial class StudentView : Page
    {
        public StudentView()
        {
            InitializeComponent();
        }

        private void mainContent_Loaded(object sender, RoutedEventArgs e)
        {
            Database.populateStudentListview(this);
            viewStudentBtn.FontWeight = FontWeights.ExtraBold;
        }

        private void addStudentBtn_Click_1(object sender, RoutedEventArgs e)
        {
            StudentAdd stdtAddWindow = new StudentAdd();
            stdtAddWindow.Content = null;
            mainContent.Children.Add(stdtAddWindow.mainContent);

            viewStudentBtn.FontWeight = FontWeights.Normal;
            addStudentBtn.FontWeight = FontWeights.ExtraBold;
            updateStudentBtn.FontWeight = FontWeights.Normal;
            deleteStudentBtn.FontWeight = FontWeights.Normal;
            searchStudentBtn.FontWeight = FontWeights.Normal;
        }

        private void updateStudentBtn_Click_1(object sender, RoutedEventArgs e)
        {
            StudentUpdate stdtUpdateWindow = new StudentUpdate();
            stdtUpdateWindow.Content = null;
            mainContent.Children.Add(stdtUpdateWindow.mainContent);

            viewStudentBtn.FontWeight = FontWeights.Normal;
            addStudentBtn.FontWeight = FontWeights.Normal;
            updateStudentBtn.FontWeight = FontWeights.ExtraBold;
            deleteStudentBtn.FontWeight = FontWeights.Normal;
            searchStudentBtn.FontWeight = FontWeights.Normal;
        }

        private void deleteStudentBtn_Click_1(object sender, RoutedEventArgs e)
        {
            StudentDelete stdtDeletWindow = new StudentDelete();
            stdtDeletWindow.Content = null;
            mainContent.Children.Add(stdtDeletWindow.mainContent);

            viewStudentBtn.FontWeight = FontWeights.Normal;
            addStudentBtn.FontWeight = FontWeights.Normal;
            updateStudentBtn.FontWeight = FontWeights.Normal;
            deleteStudentBtn.FontWeight = FontWeights.ExtraBold;
            searchStudentBtn.FontWeight = FontWeights.Normal;
        }

        private void searchStudentBtn_Click_1(object sender, RoutedEventArgs e)
        {
            StudentSearch stdtSearchWindow = new StudentSearch();
            stdtSearchWindow.Content = null;
            mainContent.Children.Add(stdtSearchWindow.mainContent);

            viewStudentBtn.FontWeight = FontWeights.Normal;
            addStudentBtn.FontWeight = FontWeights.Normal;
            updateStudentBtn.FontWeight = FontWeights.Normal;
            deleteStudentBtn.FontWeight = FontWeights.Normal;
            searchStudentBtn.FontWeight = FontWeights.ExtraBold;
        }

        private void stdtView_Cancel_Click_1(object sender, RoutedEventArgs e)
        {
            displayStdtDetailsLstvw.SelectedItem = null;
        }

        private void stdtView_Delete_Click_1(object sender, RoutedEventArgs e)
        {
            StudentDelete stdtDeleteWindow = new StudentDelete();
            stdtDeleteWindow.Content = null;
            mainContent.Children.Add(stdtDeleteWindow.mainContent);

            DataRowView dr = (DataRowView)displayStdtDetailsLstvw.SelectedItem;
            string x = dr.Row["userID"].ToString();
            stdtDeleteWindow.stdtIDDeleteCmbx.Text = x;
        }

        private void stdtView_Update_Click_1(object sender, RoutedEventArgs e)
        {
            StudentUpdate stdtUpdateWindow = new StudentUpdate();
            stdtUpdateWindow.Content = null;
            mainContent.Children.Add(stdtUpdateWindow.mainContent);

            DataRowView dr = (DataRowView)displayStdtDetailsLstvw.SelectedItem;
            string x = dr.Row["userID"].ToString();
            stdtUpdateWindow.stdtIDUpdateCmbx.Text = x;
        }
    }
}
